﻿{% extends "base.html" %}

{% block breadcrumb %}
    {{ block.super }}
    {% load breadcrumb_tags %}
    {% add_crumb 'Báo cáo' 'department_report' %}
    {% add_crumb 'Học lực theo huyện'  %}
	
{% endblock %}

{% block js  %}
	<script>
        $(document).ready(function () {
			$("#year").change(function(){
				//alert("chao");
				$("#term").val("-1");
			})
            $('#term').change(function () {
                var year = $('#year').val().split("-")[0];
                var term = $('#term').val();
                if (term != '-1' )
                    window.location.href = "/school/report/learningByDistrict/" + year +"/"+term;
            })
			var nextYear = {{yearNumber}}+1;
			var yearString="{{yearNumber}}-"+nextYear; 
			$("#year").val(yearString);
			$("#term").val("{{termNumber}}");
		});
	</script>
{% endblock %}

{% block content %}
    <div class="btn-toolbar form-inline pagination-centered">
		Năm học
		<select id="year" style="width:100px">
			{% for i in yearList %}
				<option value={{i}}> {{i}} </option>
			{% endfor %}	
		</select>
		Học kỳ
        <select id="term" style="width:100px">
			<option value='-1'> ----------- </option>
			<option value='1'> Học kỳ I </option>
			<option value='2'> Học kỳ II  </option>
			<option value='3'> Cả năm  </option>
		</select>	
        <a class='btn' href="{% url learning_by_district yearNumber termNumber 1 %}">Xuất ra Excel </a>
    </div>
	<table class="table table-striped grid">
    <thead>
	<tr>
		<th rowspan =2  >
			Huyện
		</th>
		<th rowspan =2 >
			Trường
		</th>
		<th rowspan =2 >
			Tổng số
		</th>
		<th colspan="2" >
			Giỏi
		</th>
		<th colspan="2" >
			Khá
		</th>
		<th colspan="2">
			Trung bình
		</th>
		<th colspan="2">
			Yếu
		</th>
		<th colspan="2">
			Kém
		</th>
	</tr>
	<tr>	
        <th>SL</th>
        <th>%</th>
        <th>SL</th>
        <th>%</th>
        <th>SL</th>
        <th>%</th>
        <th>SL</th>
        <th>%</th>
        <th>SL</th>
        <th>%</th>
	</tr>
    </thead>
    <tbody>
	{% for aList in list %}
		{% for s,subList in aList %}
			{% if s == '1' %}	
			<tr style="font-weight:bold">
				<td>
					Tổng
				</td>
				<td>
				</td>
			{% else %}
			<tr >
				<td>
					{{s.district}}
				</td>
				<td>
					{{s.name}}
				</td>
			{% endif %}
			
			{% for l in subList %}
			<td>
				{{l}}		
			</td>
			{% endfor %}
		</tr>	
		{% if s == '1' %}
			
			<tr>
				<td>&nbsp </td><td>&nbsp </td><td>&nbsp </td><td>&nbsp </td><td>&nbsp </td><td>&nbsp </td><td>&nbsp </td>
				<td>&nbsp </td><td>&nbsp </td><td>&nbsp </td><td>&nbsp </td><td>&nbsp </td><td>&nbsp </td>
			</tr>
		{% endif %}
		{% endfor %}			
	{% endfor %}
    </tbody>
    </table>
{% endblock %}
